package com.shuoyue.ycgk.ui.main.adapter;

import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.base.baseadapter.AppBaseQuickAdapter;
import com.shuoyue.ycgk.entity.Course;

import java.util.List;

public class HomeCourseAdapter extends AppBaseQuickAdapter<Course> {
    public HomeCourseAdapter(@Nullable List<Course> data) {
        super(R.layout.item_home_course, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Course item) {
        helper.addOnClickListener(R.id.lay_all);
        helper.setText(R.id.text, item.getName());
        Glide.with(mContext).load(item.getCover()).error(R.mipmap.img_loading_gray).into((ImageView) helper.getView(R.id.img));
        int pos_4 = helper.getAdapterPosition() % 4;
        switch (pos_4) {
            case 0:
                helper.setImageResource(R.id.bg, R.mipmap.home_course_bg_1);
                break;
            case 1:
                helper.setImageResource(R.id.bg, R.mipmap.home_course_bg_2);
                break;
            case 2:
                helper.setImageResource(R.id.bg, R.mipmap.home_course_bg_3);
                break;
            case 3:
                helper.setImageResource(R.id.bg, R.mipmap.home_course_bg_4);
                break;
        }
    }
}
